/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class DeleteLibro2Data {
	public void deleteTestData() throws PersistentException {
		PersistentTransaction t = orm.Libro2PersistentManager.instance().getSession().beginTransaction();
		try {
			orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
			orm.dao.EmpresaDAO lormEmpresaDAO = lDAOFactory.getEmpresaDAO();
			orm.Empresa lormEmpresa = lormEmpresaDAO.loadEmpresaByQuery(null, null);
			// Delete the persistent object
			lormEmpresaDAO.delete(lormEmpresa);
			orm.dao.LibroDAO lormLibroDAO = lDAOFactory.getLibroDAO();
			orm.Libro lormLibro = lormLibroDAO.loadLibroByQuery(null, null);
			// Delete the persistent object
			lormLibroDAO.delete(lormLibro);
			orm.dao.ResultadoDAO lormResultadoDAO = lDAOFactory.getResultadoDAO();
			orm.Resultado lormResultado = lormResultadoDAO.loadResultadoByQuery(null, null);
			// Delete the persistent object
			lormResultadoDAO.delete(lormResultado);
			orm.dao.PreguntaDAO lormPreguntaDAO = lDAOFactory.getPreguntaDAO();
			orm.Pregunta lormPregunta = lormPreguntaDAO.loadPreguntaByQuery(null, null);
			// Delete the persistent object
			lormPreguntaDAO.delete(lormPregunta);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public static void main(String[] args) {
		try {
			DeleteLibro2Data deleteLibro2Data = new DeleteLibro2Data();
			try {
				deleteLibro2Data.deleteTestData();
			}
			finally {
				orm.Libro2PersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
